import 'package:flutter/material.dart';
import 'package:vehicle_management/pages/my_task_page/ServiceLocator.dart';
import 'package:vehicle_management/pages/my_task_page/TelAndSmsService.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

final TelAndSmsService _service = locator<TelAndSmsService>();
final String number = "123456789";
final String email = "12345@example.com";

tranisitIng(List list, index, hasmore, context) {
  ScreenUtil.instance = ScreenUtil(width: 750, height: 1334)..init(context);
  if (index == list.length - 1) {
        return Container(
  child: Column(
    children: <Widget>[
      ///起点 终点  和轨迹 Row排列方便
      Container(
        decoration: BoxDecoration(color: Colors.white, boxShadow: <BoxShadow>[
          BoxShadow(
            color: Colors.grey[400],
          ),
        ]),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: <Widget>[
            Expanded(
                flex: 3,
                child: Container(
                  color: Color.fromRGBO(255, 255, 255, 1),
                  child: Padding(
                    padding: EdgeInsets.fromLTRB(20, 10, 32, 10),
                    child: Column(
                      children: <Widget>[
                        ///起点
                        Row(
                          children: <Widget>[
                            Container(
                              width: ScreenUtil().setWidth(40),
                              height: ScreenUtil().setHeight(40),
                              color: Color(0xff62B500),
                              margin: EdgeInsets.fromLTRB(0, 0, 10, 0),
                              child: Text(
                                "起",
                                textAlign: TextAlign.center,
                                style: TextStyle(
                                  fontSize: ScreenUtil().setSp(24),
                                  color: Colors.white,
                                ),
                              ),
                            ),
                            Container(
                              width: ScreenUtil().setWidth(400),
                              child: Text(
                                list[index]['fromAddress'],
                                overflow: TextOverflow.ellipsis,
                                maxLines: 2,
                                style: TextStyle(
                                  fontSize: ScreenUtil().setSp(26),
                                  color: Color(0xff0E0E0E),
                                ),
                              ),
                            ),
                          ],
                        ),
                        Container(
                          height: ScreenUtil().setHeight(50),
                          margin: EdgeInsets.fromLTRB(
                              ScreenUtil().setHeight(20), 0, 0, 0),
                          decoration: BoxDecoration(
                            border: Border(
                                left: BorderSide(
                                    color: Colors.grey[200],
                                    width: 1,
                                    style: BorderStyle.solid)),
                          ),
                        ),

                        ///终点
                        Row(
                          children: <Widget>[
                            Container(
                              width: ScreenUtil().setWidth(40),
                              height: ScreenUtil().setHeight(40),
                              color: Color(0xffF54336),
                              margin: EdgeInsets.fromLTRB(0, 0, 10, 0),
                              child: Text(
                                "终",
                                textAlign: TextAlign.center,
                                style: TextStyle(
                                  fontSize: ScreenUtil().setSp(24),
                                  color: Colors.white,
                                ),
                              ),
                            ),
                            Container(
                              width: ScreenUtil().setWidth(400),
                              child: Text(
                                list[index]['fromAddress'],
                                overflow: TextOverflow.ellipsis,
                                maxLines: 2,
                                style: TextStyle(
                                  fontSize: ScreenUtil().setSp(26),
                                  color: Color(0xff0E0E0E),
                                ),
                              ),
                            ),
                          ],
                        )
                      ],
                    ),
                  ),
                )),
            Expanded(
              child: Container(
                color: Color.fromRGBO(255, 255, 255, 0.8),
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: <Widget>[
                    // Image.asset('images/transitLine.png'),
                    FlatButton(
                        child: Text(
                          "查看轨迹",
                          style: TextStyle(
                            color: Color(0xffFB5858),
                            fontSize: ScreenUtil().setSp(26),
                          ),
                        ),
                        onPressed: () {})
                  ],
                ),
              ),
            )
          ],
        ),
      ),
      ///联系人电话
      Container(
        padding: EdgeInsets.fromLTRB(30, 5, 10, 15),
        decoration: BoxDecoration(color: Colors.white, boxShadow: <BoxShadow>[
          BoxShadow(
            color: Colors.grey[400],
          ),
        ]),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: <Widget>[
            //涉及到widget的大小或者边框的时候，使用container包裹
            Container(
              child: Row(
                children: <Widget>[
                  ///联系人
                  Text(
                     list[index]['senderName']??'暂无',
                    style: TextStyle(
                      fontSize: ScreenUtil().setSp(26),
                      color: Color(0xfff0E0E0E),
                    ),
                  ),

                  /// 车牌号
                  Container(
                    alignment: Alignment.center,
                    color: Color(0xfff2f2f2),
                    padding: EdgeInsets.fromLTRB(10, 5, 10, 5),
                    margin: EdgeInsets.fromLTRB(20, 0, 0, 0),
                    child: Text(
                     list[index]['vehicleNo']??'暂无',
                      style: TextStyle(
                        fontSize: ScreenUtil().setSp(26),
                        color: Color(0xff0E0E0E),
                      ),
                    ),
                  )
                ],
              ),
            ),
            Container(
              padding: EdgeInsets.fromLTRB(0, 0, 20, 10),
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  IconButton(
                      icon: Icon(
                        Icons.phone,
                        color: Colors.red,
                      ),
                      onPressed: () {
                        _service.call(list[index]['receiverTelephone']);
                      })
                ],
              ),
            ),
          ],
        ),
      ),
      Container(
        padding: EdgeInsets.fromLTRB(0, 10, 20, 10),
        decoration: BoxDecoration(color: Colors.white),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.end,
          children: <Widget>[
            Container(
              height: ScreenUtil().setHeight(58),
              decoration: BoxDecoration(
                borderRadius: BorderRadius.all(Radius.circular(5)),
              ),
              alignment: Alignment.center,
              child: RaisedButton(
                  color: Color(0xffFB5858),
                  textColor: Colors.white,
                  child: Text(
                    "确认收货",
                    style: TextStyle(fontSize: ScreenUtil().setSp(26)),
                  ),
                  onPressed: () {
                    /// 确认收货
                  }),
            )
          ],
        ),
      ),
      SizedBox(
        height: ScreenUtil().setHeight(20),
      ),
      Divider(),
      getMoreWidget(hasmore),    
    ],
  ),
   
 );
  }else{
      return Container(
  child: Column(
    children: <Widget>[
      ///起点 终点  和轨迹 Row排列方便
      Container(
        decoration: BoxDecoration(color: Colors.white, boxShadow: <BoxShadow>[
          BoxShadow(
            color: Colors.grey[400],
          ),
        ]),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: <Widget>[
            Expanded(
                flex: 3,
                child: Container(
                  color: Color.fromRGBO(255, 255, 255, 1),
                  child: Padding(
                    padding: EdgeInsets.fromLTRB(20, 10, 32, 10),
                    child: Column(
                      children: <Widget>[
                        ///起点
                        Row(
                          children: <Widget>[
                            Container(
                              width: ScreenUtil().setWidth(40),
                              height: ScreenUtil().setHeight(40),
                              color: Color(0xff62B500),
                              margin: EdgeInsets.fromLTRB(0, 0, 10, 0),
                              child: Text(
                                "起",
                                textAlign: TextAlign.center,
                                style: TextStyle(
                                  fontSize: ScreenUtil().setSp(24),
                                  color: Colors.white,
                                ),
                              ),
                            ),
                            Container(
                              width: ScreenUtil().setWidth(400),
                              child: Text(
                                list[index]['fromAddress'],
                                overflow: TextOverflow.ellipsis,
                                maxLines: 2,
                                style: TextStyle(
                                  fontSize: ScreenUtil().setSp(26),
                                  color: Color(0xff0E0E0E),
                                ),
                              ),
                            ),
                          ],
                        ),
                        Container(
                          height: ScreenUtil().setHeight(50),
                          margin: EdgeInsets.fromLTRB(
                              ScreenUtil().setHeight(20), 0, 0, 0),
                          decoration: BoxDecoration(
                            border: Border(
                                left: BorderSide(
                                    color: Colors.grey[200],
                                    width: 1,
                                    style: BorderStyle.solid)),
                          ),
                        ),

                        ///终点
                        Row(
                          children: <Widget>[
                            Container(
                              width: ScreenUtil().setWidth(40),
                              height: ScreenUtil().setHeight(40),
                              color: Color(0xffF54336),
                              margin: EdgeInsets.fromLTRB(0, 0, 10, 0),
                              child: Text(
                                "终",
                                textAlign: TextAlign.center,
                                style: TextStyle(
                                  fontSize: ScreenUtil().setSp(24),
                                  color: Colors.white,
                                ),
                              ),
                            ),
                            Container(
                              width: ScreenUtil().setWidth(400),
                              child: Text(
                                list[index]['fromAddress'],
                                overflow: TextOverflow.ellipsis,
                                maxLines: 2,
                                style: TextStyle(
                                  fontSize: ScreenUtil().setSp(26),
                                  color: Color(0xff0E0E0E),
                                ),
                              ),
                            ),
                          ],
                        )
                      ],
                    ),
                  ),
                )),
            Expanded(
              child: Container(
                color: Color.fromRGBO(255, 255, 255, 0.8),
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: <Widget>[
                    // Image.asset('images/transitLine.png'),
                    FlatButton(
                        child: Text(
                          "查看轨迹",
                          style: TextStyle(
                            color: Color(0xffFB5858),
                            fontSize: ScreenUtil().setSp(26),
                          ),
                        ),
                        onPressed: () {})
                  ],
                ),
              ),
            )
          ],
        ),
      ),
      ///联系人电话
      Container(
        padding: EdgeInsets.fromLTRB(30, 5, 10, 15),
        decoration: BoxDecoration(color: Colors.white, boxShadow: <BoxShadow>[
          BoxShadow(
            color: Colors.grey[400],
          ),
        ]),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: <Widget>[
            //涉及到widget的大小或者边框的时候，使用container包裹
            Container(
              child: Row(
                children: <Widget>[
                  ///联系人
                  Text(
                     list[index]['senderName']??'暂无',
                    style: TextStyle(
                      fontSize: ScreenUtil().setSp(26),
                      color: Color(0xfff0E0E0E),
                    ),
                  ),

                  /// 车牌号
                  Container(
                    alignment: Alignment.center,
                    color: Color(0xfff2f2f2),
                    padding: EdgeInsets.fromLTRB(10, 5, 10, 5),
                    margin: EdgeInsets.fromLTRB(20, 0, 0, 0),
                    child: Text(
                      list[index]['vehicleNo']??'暂无',
                      style: TextStyle(
                        fontSize: ScreenUtil().setSp(26),
                        color: Color(0xff0E0E0E),
                      ),
                    ),
                  )
                ],
              ),
            ),
            Container(
              padding: EdgeInsets.fromLTRB(0, 0, 20, 10),
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  IconButton(
                      icon: Icon(
                        Icons.phone,
                        color: Colors.red,
                      ),
                      onPressed: () {
                        _service.call(list[index]['receiverTelephone']);
                      })
                ],
              ),
            ),
          ],
        ),
      ),
      Container(
        padding: EdgeInsets.fromLTRB(0, 10, 20, 10),
        decoration: BoxDecoration(color: Colors.white),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.end,
          children: <Widget>[
            Container(
              height: ScreenUtil().setHeight(58),
              decoration: BoxDecoration(
                borderRadius: BorderRadius.all(Radius.circular(5)),
              ),
              alignment: Alignment.center,
              child: RaisedButton(
                  color: Color(0xffFB5858),
                  textColor: Colors.white,
                  child: Text(
                    "确认收货",
                    style: TextStyle(fontSize: ScreenUtil().setSp(26)),
                  ),
                  onPressed: () {
                    /// 确认收货
                  }),
            )
          ],
        ),
      ),
      SizedBox(
        height: ScreenUtil().setHeight(20),
      ),
    ],
  ),
   
 );
  }
 
}
//加载中的圈圈
Widget getMoreWidget(hasMore) {
  if (hasMore) {
    return Center(
      child: Padding(
        padding: EdgeInsets.all(10.0),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: <Widget>[
            Text(
              '加载中...',
              style: TextStyle(fontSize: 16.0),
            ),
            CircularProgressIndicator(
              strokeWidth: 1.0,
            )
          ],
        ),
      ),
    );
  } else {
    return Center(
      child: Text("--我是有底线的--"),
    );
  }
}
